# We have to get access to all ast types to use
# 'eval' to rebuild the ast
from ast import *
import json


def rebuild_ast(ast_str):
    return eval(json.loads(ast_str))


def vertex_attr(node, key):
    for prop in node.properties:
        if prop.key == key:
            return prop.value
    return None


def vertex_attr_str(node, key):
    attr = vertex_attr(node, key)
    if attr is not None:
        return str(attr)
    return None
